package com.milling.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.milling.common.annotation.Log;
import com.milling.common.core.controller.BaseController;
import com.milling.common.core.domain.AjaxResult;
import com.milling.common.enums.BusinessType;
import com.milling.business.domain.WmsDrillinfoStock;
import com.milling.business.service.IWmsDrillinfoStockService;
import com.milling.common.utils.poi.ExcelUtil;
import com.milling.common.core.page.TableDataInfo;

/**
 * 后库库存Controller
 *
 * @author X
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/business/stockinfo")
public class WmsDrillinfoStockController extends BaseController
{
    @Autowired
    private IWmsDrillinfoStockService wmsDrillinfoStockService;

    /**
     * 查询后库库存列表
     */
    @PreAuthorize("@ss.hasPermi('business:stockinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsDrillinfoStock wmsDrillinfoStock)
    {
        startPage();
        List<WmsDrillinfoStock> list = wmsDrillinfoStockService.selectWmsDrillinfoStockList(wmsDrillinfoStock);
        return getDataTable(list);
    }

    /**
     * 导出后库库存列表
     */
    @PreAuthorize("@ss.hasPermi('business:stockinfo:export')")
    @Log(title = "后库库存", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsDrillinfoStock wmsDrillinfoStock)
    {
        List<WmsDrillinfoStock> list = wmsDrillinfoStockService.selectWmsDrillinfoStockList(wmsDrillinfoStock);
        ExcelUtil<WmsDrillinfoStock> util = new ExcelUtil<WmsDrillinfoStock>(WmsDrillinfoStock.class);
        util.exportExcel(response, list, "后库库存数据");
    }

    /**
     * 获取后库库存详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:stockinfo:query')")
    @GetMapping(value = "/{drillInfo}")
    public AjaxResult getInfo(@PathVariable("drillInfo") String drillInfo)
    {
        return success(wmsDrillinfoStockService.selectWmsDrillinfoStockByDrillInfo(drillInfo));
    }

    /**
     * 新增后库库存
     */
    @PreAuthorize("@ss.hasPermi('business:stockinfo:add')")
    @Log(title = "后库库存", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsDrillinfoStock wmsDrillinfoStock)
    {
        return toAjax(wmsDrillinfoStockService.insertWmsDrillinfoStock(wmsDrillinfoStock));
    }

    /**
     * 修改后库库存
     */
    @PreAuthorize("@ss.hasPermi('business:stockinfo:edit')")
    @Log(title = "后库库存", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsDrillinfoStock wmsDrillinfoStock)
    {
        return toAjax(wmsDrillinfoStockService.updateWmsDrillinfoStock(wmsDrillinfoStock));
    }

    /**
     * 删除后库库存
     */
    @PreAuthorize("@ss.hasPermi('business:stockinfo:remove')")
    @Log(title = "后库库存", businessType = BusinessType.DELETE)
    @DeleteMapping("/{drillInfos}")
    public AjaxResult remove(@PathVariable String[] drillInfos)
    {
        return toAjax(wmsDrillinfoStockService.deleteWmsDrillinfoStockByDrillInfos(drillInfos));
    }
}
